<template>
  <div class="footer">
    <div class="footer_box">
      <div class="footer_list"
           v-for="(item,index) in footerList"
           @click="selectNav(index)">
        <div class="footer_list_box">
          <div class="footer_list_box_img">
            <img :src="inds==index?item.selected:item.before"
                 alt="">
          </div>
          <div class="footer_list_box_name"
               v-html="item.name"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Afooter',
  data () {
    return {
      inds: 0,
      footerList: [
        {
          before: '../../static/footer/ioc-01.png',
          selected: '../../static/footer/ioc--01.png',
          name: '首页'
        },
        {
          before: '../../static/footer/ioc-03.png',
          selected: '../../static/footer/ioc--03.png',
          name: '发布'
        },
        {
          before: '../../static/footer/ioc-04.png',
          selected: '../../static/footer/ioc--04.png',
          name: '消息'
        },
        {
          before: '../../static/footer/ioc-05.png',
          selected: '../../static/footer/ioc--05.png',
          name: '我的'
        }
      ]
    }
  },
  methods: {
    selectNav (index) {
      switch (index) {
        case 0:
          this.$router.push({ name: 'home' })
          break;
        case 1:
          this.$router.push({ name: 'publish' })
          break;
        case 2:
          this.$router.push({ name: 'other' })
          break;
        case 3:
          this.$router.push({ name: 'team' })
          break;
      }
      this.$emit('getTitle', this.footerList[index].name)
      this.inds = index

    }
  },
  watch: {
    inds () {
      var list = document.querySelectorAll('.footer_list_box_name')
      for (var i = 0; i < list.length; i++) {
        list[i].style.color = 'black'
        if (i == this.inds) {
          list[i].style.color = '#eb4f38'
        }
      }
    }
  }
}
</script>

<style lang="scss">
.footer_box {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 100px;
  background: #fff;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.12);

  .footer_list {
    width: 25%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 0;

    .footer_list_box {
      .footer_list_box_img {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;

        img {
          height: 0.7rem;
          width: 0.7rem;
        }
      }

      .footer_list_box_name {
        padding-top: 0.1rem;
        width: 100%;
        text-align: center;
        /*font-size: .6rem*/
      }
    }
  }
}
</style>
